const Golbal = require("../../lib/js/global.js");
const SERVICE = require("../../lib/js/service.js");

Page({
  data:{
    inputValue:null,
    regDialog:{   //模板数据
      quit:"quit",
      button:"viewDetail",
      mobileFocus:false
    },
    showRegDialog:false, //是否显示模板
  },
  onLoad(){
   
  },

  /*分享*/ 
  onShareAppMessage(){
  },
  
  /*手机号*/
  Mobile(e){
    this.setData({
      inputVal:e.detail.value,
      isActive: Golbal.checkPhone(e.detail.value) === false ? false : true
    });
    
  },
  
  /*清除手机号*/ 
  Clear(){
    this.setData({
      inputVal: null,
      isActive: false,
      mobileFocus: true      
    });
  },

  /*提交手机号*/ 
  formSubmit(e){
    let td = this.data, mobile = e.detail.value.mobile;
    if (mobile.length > 0 && Golbal.checkPhone(mobile) != false){
      SERVICE.POST(SERVICE.URL.vccode, {
        phone: mobile,
        register: "register",
      }, (status, res) => {
        if (status) {
          wx.navigateTo({
            url: "../get-vccode/get-vccode?mobile=" + mobile
          });
        }else{
          wx.showToast({
            title: res.data.message,
            icon:"none",
            mask: true
          })
        }
      });
    }
  }
});